package com.forenow.demo.ListTest;

import com.forenow.demo.Game.Rand;

import java.util.*;

public class Grouping {
        public static void main(String[] args) {
            List<String> arrlist=new ArrayList<>();
            Map<Integer,String> map=new HashMap<>();
            String nba []= {"骑士","勇士","湖人","热火","老鹰","猛龙","篮网","凯尔特人","小牛","活塞",
                    "公牛","魔术","爵士","开拓","火箭","国王"};
            int j = 0;
            for (int i = 0; i <nba.length ; i++) {
                arrlist.add(nba[i]);
            }

            //创建一个产生随机数的对象
            Random r = new Random();

            //创建一个存储随机数的集合
            List<Integer> list=new ArrayList<>();
            //定义一个统计变量
            int count = 0;
            String s = null;
            while(count <16){
                int number = (int)(Math.random()*16)+0;

                //判断number是否在集合中存在
                if(!list.contains(number)){
                    //不在集合中，就添加
                    list.add(number);
                    count++;
                }
            }
            int k=1;
            for (int i = 0; i <list.size(); i++) {
                    s = arrlist.get(list.get(i));
                    map.put(k,s);
                    k++;
            }
            Set<Map.Entry<Integer, String>> entries = map.entrySet();
            Iterator<Map.Entry<Integer, String>> iterator = entries.iterator();
            while (iterator.hasNext()){
                Map.Entry<Integer, String> next = iterator.next();

                Integer key = next.getKey();
                String value = next.getValue();
                System.out.println(key+"-----"+value);
                    if (key %4==0) {
                        System.out.println();
                    }

            }
        }
}
